Ext.ns('suce.ssd');

suce.ssd.view = function (config) {

    return new Ext.Window(Ext.apply({

        title: 'Hoja de SSD',
        height: 600,
        width: 800,
        layout: 'border',

        initComponent: function () {
            var me = this,
                form;

            bookTplMarkup1 = ['<div  id="ssddiv">{data0}</div>'];
            //bookTplMarkup2 = ['{data}'];

            me.bookTpl1 = Ext.create('Ext.Template', bookTplMarkup1);
            //me.bookTpl2 = Ext.create('Ext.Template', bookTplMarkup2);

            me.panelC = new Ext.Panel({
                region: 'center',
                //title: 'SUCE Actual',
                flex: 1,
                border: false,
                autoScroll: true,
                split: true,
                bodyStyle: 'padding:10px;',
                items: [{}],
                bbar: [{ text: '<b>Imprimir</b>', itemId: 'btnPrint', handler: me.imprimir, scope: me, iconCls: 'tb-print'}]
            });

            /* me.panelE = new Ext.Panel({
            region: 'east',
            title: 'SUCE Anterior',
            flex: 1,
            border: false,
            autoScroll: true,
            split: true,
            bodyStyle: 'padding:10px;',
            items: [{}]
            });*/

            me.items = [me.panelC/*, me.panelE*/];
            Ext.Window.prototype.initComponent.call(me);
        },

        show: function (p) { // p --> {idsolicitud, idversion}
            var me = this;
            p = p || {};
            Ext.Window.prototype.show.call(me);
            me.setTitle('Hoja de SSD de la SUCE: ' + p.docnumero);
            callServer('Solicitud.ashx', { C: 'GETCOMPARE', idsolicitud: p.idsolicitud, idversion: p.idversion }, function (v) {
                v = Ext.decode(v);
                var html1 = me.getHtml(v.suceact, v.prodsuceact);
                //html2 = me.getHtml(v.suceant, v.prodsuceant);
                me.bookTpl1.overwrite(me.panelC.body, { data0: html1 });
            }, me);


        },


        imprimir: function (j, v) {
            var ficha = document.getElementById('ssdhoja');
            var ventimp = window.open('http://localhost:61855/DIGESA/ArchivoDocumentario/Reporte/HojaSSD.aspx?IDSSD=41717', 'popimpr');
            //ventimp.document.write('<link href="ext/css/main.css" rel="stylesheet" type="text/css" />');
            //ventimp.document.write(ficha.innerHTML);
            //ventimp.document.close();
            //ventimp.print();
            //ventimp.close();
        },

        getHtml: function (j, v) {
            return '<iframe id="ssdhoja" frameborder="0" src="http://localhost:61855/DIGESA/ArchivoDocumentario/Reporte/HojaSSD.aspx?IDSSD=41717" width="100%" height="510px"  ></iframe>';
        }

    }, config));
};